#!/bin/bash

while :
do
    echo "请选择你想要使用的功能:"
    echo "1.创建新用户"
    echo "2.删除用户"
    echo "3.查看用户"
    echo "4.退出"
    read -p "请输入你的选择:" options
    if ["$options"==1]||["$options"==2]||["$options"==3]||["$options"==4]
    then
        case $options in
        1)
            read -p "请输入用户名:" username
            if id $username &>/dev/null
            then
                echo "$username is exist!"
            else
                read -s -p "请设置密码:" password
                useradd $username &>/dev/null
                echo $password | $username --stdin &>/dev/null
                echo -e "\n create $username ok!"
            fi 
            ;;
        2)
            read -p "请输入要删除的用户名:" username
            userdel -r $username
            ;;
        3)
            read -p "请输入想要查询的用户名:" username
            id $username
            ;;
        4)
            echo "退出!"
            exit
        esac
    else
        echo "请输入数字1或2或3或4!"
    fi
done
